package uniandes.moviles.antid.mundo;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Manages the contact with the database.
 * @author Julio Mendoza
 *
 */
public class PersistenceManager extends SQLiteOpenHelper
{
	/**
	 * Database version.
	 */
	public final static int VERSION = 2;
	
	/**
	 *The data base's name. 
	 */
	public final static String DB_NAME = "AntiDyDAta";
	
	/**
	 * The name of the users table.
	 */
	public final static String TABLE_USERS = "users";
	
	/**
	 * Query to create the users table.
	 */
	private final static String CREATE_USERS_TABLE = "CREATE TABLE IF NOT EXISTS " +  TABLE_USERS + " (id INTEGER PRIMARY KEY, userName TEXT, password TEXT, name TEXT, role INTEGER)";
	
	/**
	 * Creates a new persistence manager.
	 * @param context Context the manager is executed in.
	 */
	public PersistenceManager(Context context) 
	{
		super(context, DB_NAME, null, VERSION);		
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		
		db.execSQL(CREATE_USERS_TABLE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// Not implemented.
		
	}
		
}
